/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.interpreter.backends.rdf;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import xowl.interpreter.frontends.VocRDF;
import xowl.interpreter.frontends.VocOWL2;

/**
 *
 * @author Laurent WOUTERS
 */
public class TranslatorXOWL_RDF {
    private xowl.interpreter.IRIProvider iriProvider;
    private RDFGraph graph;

    public RDFGraph getGraph() { return graph; }

    public TranslatorXOWL_RDF(xowl.interpreter.IRIProvider iriProvider) {
        this(iriProvider, new RDFGraph());
    }
    public TranslatorXOWL_RDF(xowl.interpreter.IRIProvider iriProvider, RDFGraph graph) {
        this.iriProvider = iriProvider;
        this.graph = graph;
    }
    
    public Translation translateAxiom(xowl.interpreter.impl.Evaluator evaluator, TranslatorContext context, boolean translateAnnotations, boolean evalDynamics, xowl.lang.owl2.Axiom axiom) throws xowl.interpreter.XOWLException {
        Job job = new Job(evaluator, context, translateAnnotations, evalDynamics);
        job.addAxiom(axiom);
        return job.execute();
    }
    public Translation translateAxioms(xowl.interpreter.impl.Evaluator evaluator, boolean translateAnnotations, boolean evalDynamics, Collection<xowl.lang.owl2.Axiom> axioms) throws xowl.interpreter.XOWLException {
        Job job = new Job(evaluator, null, translateAnnotations, evalDynamics);
        job.addAxioms(axioms);
        return job.execute();
    }
    public Translation translateAxioms(xowl.interpreter.impl.Evaluator evaluator, TranslatorContext context, boolean translateAnnotations, boolean evalDynamics, Collection<xowl.lang.owl2.Axiom> axioms) throws xowl.interpreter.XOWLException {
        Job job = new Job(evaluator, context, translateAnnotations, evalDynamics);
        job.addAxioms(axioms);
        return job.execute();
    }

    protected class Job {
        protected xowl.interpreter.impl.Evaluator evaluator;
        protected Collection<xowl.lang.owl2.Axiom> originals;
        protected Collection<RDFTriple> triples;
        protected TranslatorContext context;
        protected boolean translateAnnotations;
        protected boolean evalDynamics;

        public Job(xowl.interpreter.impl.Evaluator evaluator, TranslatorContext context, boolean translateAnnotations, boolean evalDynamics) {
            this.evaluator = evaluator;
            this.originals = new ArrayList<xowl.lang.owl2.Axiom>();
            this.triples = new ArrayList<RDFTriple>();
            this.context = context;
            if (this.context == null)
                this.context = new TranslatorContext();
            this.translateAnnotations = translateAnnotations;
            this.evalDynamics = evalDynamics;
        }

        public void addAxiom(xowl.lang.owl2.Axiom axiom) { originals.add(axiom); }
        public void addAxioms(Collection<xowl.lang.owl2.Axiom> axioms) { originals.addAll(axioms); }

        public Translation execute() throws xowl.interpreter.XOWLException {
            for (xowl.lang.owl2.Axiom axiom : originals)
                translate_axiom(axiom);
            return new Translation(triples, context);
        }

        
        protected XOWLDynamicNode getDynamicNode(xowl.lang.owl2.Expression exp) {
            XOWLDynamicNode node = new XOWLDynamicNode(exp);
            return node;
        }
        protected XOWLDynamicNode getDynamicNode(xowl.lang.owl2.Expression exp, java.lang.Class type) {
            XOWLDynamicNode node = new XOWLDynamicNode(exp);
            node.addType(type);
            return node;
        }
        protected RDFTriple getTriple(RDFSubjectNode subject, String property, RDFNode object) { return new RDFTriple(subject, graph.getEntityNode(iriProvider.getIRI(property)), object); }
        protected RDFTriple getTriple(RDFSubjectNode subject, String property, String object) { return new RDFTriple(subject, graph.getEntityNode(iriProvider.getIRI(property)), graph.getEntityNode(iriProvider.getIRI(object))); }

        // <editor-fold defaultstate="collapsed" desc="translate_ontology">
        protected RDFSubjectNode translate_ontology(xowl.lang.owl2.Ontology ontology) throws xowl.interpreter.XOWLException {
            RDFSubjectNode main = graph.getEntityNode(ontology.getHasIRI());
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlOntology));
            if (translateAnnotations) {
                for (xowl.lang.owl2.Annotation annotation : ontology.getAllAnnotations())
                    translate_Annotation(main, annotation);
            }
            return main;
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate_axiom">
        protected void translate_axiom(xowl.lang.owl2.Axiom axiom) throws xowl.interpreter.XOWLException {
            java.lang.Class c = axiom.getClass();
            if (c == xowl.lang.owl2.Declaration.class) translate_axiom_Declaration((xowl.lang.owl2.Declaration)axiom);
            else if (c == xowl.lang.owl2.DatatypeDefinition.class) translate_axiom_DatatypeDefinition((xowl.lang.owl2.DatatypeDefinition)axiom);
            else if (c == xowl.lang.owl2.SubClassOf.class) translate_axiom_SubClassOf((xowl.lang.owl2.SubClassOf)axiom);
            else if (c == xowl.lang.owl2.EquivalentClasses.class) translate_axiom_EquivalentClasses((xowl.lang.owl2.EquivalentClasses)axiom);
            else if (c == xowl.lang.owl2.DisjointClasses.class) translate_axiom_DisjointClasses((xowl.lang.owl2.DisjointClasses)axiom);
            else if (c == xowl.lang.owl2.DisjointUnion.class) translate_axiom_DisjointUnion((xowl.lang.owl2.DisjointUnion)axiom);
            else if (c == xowl.lang.owl2.SubObjectPropertyOf.class) translate_axiom_SubObjectPropertyOf((xowl.lang.owl2.SubObjectPropertyOf)axiom);
            else if (c == xowl.lang.owl2.EquivalentObjectProperties.class) translate_axiom_EquivalentObjectProperties((xowl.lang.owl2.EquivalentObjectProperties)axiom);
            else if (c == xowl.lang.owl2.DisjointObjectProperties.class) translate_axiom_DisjointObjectProperties((xowl.lang.owl2.DisjointObjectProperties)axiom);
            else if (c == xowl.lang.owl2.InverseObjectProperties.class) translate_axiom_InverseObjectProperties((xowl.lang.owl2.InverseObjectProperties)axiom);
            else if (c == xowl.lang.owl2.ObjectPropertyDomain.class) translate_axiom_ObjectPropertyDomain((xowl.lang.owl2.ObjectPropertyDomain)axiom);
            else if (c == xowl.lang.owl2.ObjectPropertyRange.class) translate_axiom_ObjectPropertyRange((xowl.lang.owl2.ObjectPropertyRange)axiom);
            else if (c == xowl.lang.owl2.FunctionalObjectProperty.class) translate_axiom_FunctionalObjectProperty((xowl.lang.owl2.FunctionalObjectProperty)axiom);
            else if (c == xowl.lang.owl2.InverseFunctionalObjectProperty.class) translate_axiom_InverseFunctionalObjectProperty((xowl.lang.owl2.InverseFunctionalObjectProperty)axiom);
            else if (c == xowl.lang.owl2.ReflexiveObjectProperty.class) translate_axiom_ReflexiveObjectProperty((xowl.lang.owl2.ReflexiveObjectProperty)axiom);
            else if (c == xowl.lang.owl2.IrreflexiveObjectProperty.class) translate_axiom_IrreflexiveObjectProperty((xowl.lang.owl2.IrreflexiveObjectProperty)axiom);
            else if (c == xowl.lang.owl2.SymmetricObjectProperty.class) translate_axiom_SymmetricObjectProperty((xowl.lang.owl2.SymmetricObjectProperty)axiom);
            else if (c == xowl.lang.owl2.AsymmetricObjectProperty.class) translate_axiom_AsymmetricObjectProperty((xowl.lang.owl2.AsymmetricObjectProperty)axiom);
            else if (c == xowl.lang.owl2.TransitiveObjectProperty.class) translate_axiom_TransitiveObjectProperty((xowl.lang.owl2.TransitiveObjectProperty)axiom);
            else if (c == xowl.lang.owl2.SubDataPropertyOf.class) translate_axiom_SubDataPropertyOf((xowl.lang.owl2.SubDataPropertyOf)axiom);
            else if (c == xowl.lang.owl2.EquivalentDataProperties.class) translate_axiom_EquivalentDataProperties((xowl.lang.owl2.EquivalentDataProperties)axiom);
            else if (c == xowl.lang.owl2.DisjointDataProperties.class) translate_axiom_DisjointDataProperties((xowl.lang.owl2.DisjointDataProperties)axiom);
            else if (c == xowl.lang.owl2.DataPropertyDomain.class) translate_axiom_DataPropertyDomain((xowl.lang.owl2.DataPropertyDomain)axiom);
            else if (c == xowl.lang.owl2.DataPropertyRange.class) translate_axiom_DataPropertyRange((xowl.lang.owl2.DataPropertyRange)axiom);
            else if (c == xowl.lang.owl2.FunctionalDataProperty.class) translate_axiom_FunctionalDataProperty((xowl.lang.owl2.FunctionalDataProperty)axiom);
            else if (c == xowl.lang.owl2.SameIndividual.class) translate_axiom_SameIndividual((xowl.lang.owl2.SameIndividual)axiom);
            else if (c == xowl.lang.owl2.DifferentIndividuals.class) translate_axiom_DifferentIndividuals((xowl.lang.owl2.DifferentIndividuals)axiom);
            else if (c == xowl.lang.owl2.ClassAssertion.class) translate_axiom_ClassAssertion((xowl.lang.owl2.ClassAssertion)axiom);
            else if (c == xowl.lang.owl2.ObjectPropertyAssertion.class) translate_axiom_ObjectPropertyAssertion((xowl.lang.owl2.ObjectPropertyAssertion)axiom);
            else if (c == xowl.lang.owl2.NegativeObjectPropertyAssertion.class) translate_axiom_NegativeObjectPropertyAssertion((xowl.lang.owl2.NegativeObjectPropertyAssertion)axiom);
            else if (c == xowl.lang.owl2.DataPropertyAssertion.class) translate_axiom_DataPropertyAssertion((xowl.lang.owl2.DataPropertyAssertion)axiom);
            else if (c == xowl.lang.owl2.NegativeDataPropertyAssertion.class) translate_axiom_NegativeDataPropertyAssertion((xowl.lang.owl2.NegativeDataPropertyAssertion)axiom);
            else if (c == xowl.lang.owl2.HasKey.class) translate_axiom_HasKey((xowl.lang.owl2.HasKey)axiom);
            else if (c == xowl.lang.owl2.SubAnnotationPropertyOf.class) translate_axiom_SubAnnotationPropertyOf((xowl.lang.owl2.SubAnnotationPropertyOf)axiom);
            else if (c == xowl.lang.owl2.AnnotationPropertyDomain.class) translate_axiom_AnnotationPropertyDomain((xowl.lang.owl2.AnnotationPropertyDomain)axiom);
            else if (c == xowl.lang.owl2.AnnotationPropertyRange.class) translate_axiom_AnnotationPropertyRange((xowl.lang.owl2.AnnotationPropertyRange)axiom);
            else if (c == xowl.lang.owl2.AnnotationAssertion.class) translate_axiom_AnnotationAssertion((xowl.lang.owl2.AnnotationAssertion)axiom);
        }
        protected void translate_axiom_Declaration(xowl.lang.owl2.Declaration axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode entityNode = graph.getEntityNode(axiom.getEntity());
            RDFTriple triple = null;
            if (VocOWL2.entityClass.equals(axiom.getType()))
                triple = getTriple(entityNode, VocRDF.rdfType, VocRDF.owlClass);
            else if (VocOWL2.entityDatatype.equals(axiom.getType()))
                triple = getTriple(entityNode, VocRDF.rdfType, VocRDF.rdfsDatatype);
            else if (VocOWL2.entityNamedIndividual.equals(axiom.getType()))
                triple = getTriple(entityNode, VocRDF.rdfType, VocRDF.owlNamedIndividual);
            else if (VocOWL2.entityObjectProperty.equals(axiom.getType()))
                triple = getTriple(entityNode, VocRDF.rdfType, VocRDF.owlObjectProperty);
            else if (VocOWL2.entityDataProperty.equals(axiom.getType()))
                triple = getTriple(entityNode, VocRDF.rdfType, VocRDF.owlDataProperty);
            else if (VocOWL2.entityAnnotationProperty.equals(axiom.getType()))
                triple = getTriple(entityNode, VocRDF.rdfType, VocRDF.owlAnnotationProperty);
            if (triple != null) {
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            }
        }
        protected void translate_axiom_DatatypeDefinition(xowl.lang.owl2.DatatypeDefinition axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode dt = translate_exp_datarange(axiom.getDatatype());
            RDFSubjectNode dr = translate_exp_datarange(axiom.getDatarange());
            triples.add(getTriple(dt, VocRDF.owlEquivalentClass, dr));
        }
        protected void translate_axiom_SubClassOf(xowl.lang.owl2.SubClassOf axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode sub = translate_exp_classExpression(axiom.getClasse());
            RDFSubjectNode sup = translate_exp_classExpression(axiom.getSuperClass());
            RDFTriple triple = getTriple(sub, VocRDF.rdfsSubClassOf, sup);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_EquivalentClasses(xowl.lang.owl2.EquivalentClasses axiom) throws xowl.interpreter.XOWLException {
            List<RDFSubjectNode> elements = new ArrayList<RDFSubjectNode>();
            for (xowl.lang.owl2.ClassExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getClassSeq()))
                elements.add(translate_exp_classExpression(elem));
            for (int i=0; i!=elements.size()-1; i++) {
                RDFTriple triple = getTriple(elements.get(i), VocRDF.owlEquivalentClass, elements.get(i+1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            }
        }
        protected void translate_axiom_DisjointClasses(xowl.lang.owl2.DisjointClasses axiom) throws xowl.interpreter.XOWLException {
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.ClassExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getClassSeq()))
                elements.add(translate_exp_classExpression(elem));
            if (elements.size() == 2) {
                RDFTriple triple = getTriple((RDFSubjectNode)elements.get(0), VocRDF.owlDisjointWith, elements.get(1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            } else {
                RDFSubjectNode main = graph.getBlankNode();
                triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlAllDisjointClasses));
                triples.add(getTriple(main, VocRDF.owlMembers, translate_Sequence_Unordered(elements)));
                if (translateAnnotations) {
                    for (xowl.lang.owl2.Annotation annotation : axiom.getAllAnnotations())
                        translate_Annotation(main, annotation);
                }
            }
        }
        protected void translate_axiom_DisjointUnion(xowl.lang.owl2.DisjointUnion axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode classe = translate_exp_classExpression(axiom.getClasse());
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.ClassExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getClassSeq()))
                elements.add(translate_exp_classExpression(elem));
            RDFTriple triple = getTriple(classe, VocRDF.owlDisjointUnionOf, translate_Sequence_Unordered(elements));
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_SubObjectPropertyOf(xowl.lang.owl2.SubObjectPropertyOf axiom) throws xowl.interpreter.XOWLException {
            if (axiom.getObjectPropertyChain() != null) {
                List<RDFNode> elements = new ArrayList<RDFNode>();
                for (xowl.lang.owl2.ObjectPropertyExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getObjectPropertyChain()))
                    elements.add(translate_exp_objectPropertyExpression(elem));
                RDFSubjectNode sup = translate_exp_objectPropertyExpression(axiom.getSuperObjectProperty());
                RDFTriple triple = getTriple(sup, VocRDF.owlPropertyChainAxiom, translate_Sequence_Ordered(elements));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            } else {
                RDFSubjectNode sub = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
                RDFSubjectNode sup = translate_exp_objectPropertyExpression(axiom.getSuperObjectProperty());
                RDFTriple triple = getTriple(sub, VocRDF.rdfsSubPropertyOf, sup);
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            }
        }
        protected void translate_axiom_EquivalentObjectProperties(xowl.lang.owl2.EquivalentObjectProperties axiom) throws xowl.interpreter.XOWLException {
            List<RDFSubjectNode> elements = new ArrayList<RDFSubjectNode>();
            for (xowl.lang.owl2.ObjectPropertyExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getObjectPropertySeq()))
                elements.add(translate_exp_objectPropertyExpression(elem));
            for (int i=0; i!=elements.size()-1; i++) {
                RDFTriple triple = getTriple(elements.get(i), VocRDF.owlEquivalentProperty, elements.get(i+1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            }
        }
        protected void translate_axiom_DisjointObjectProperties(xowl.lang.owl2.DisjointObjectProperties axiom) throws xowl.interpreter.XOWLException {
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.ObjectPropertyExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getObjectPropertySeq()))
                elements.add(translate_exp_objectPropertyExpression(elem));
            if (elements.size() == 2) {
                RDFTriple triple = getTriple((RDFSubjectNode)elements.get(0), VocRDF.owlPropertyDisjointWith, elements.get(1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            } else {
                RDFSubjectNode main = graph.getBlankNode();
                triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlAllDisjointProperties));
                triples.add(getTriple(main, VocRDF.owlMembers, translate_Sequence_Unordered(elements)));
                if (translateAnnotations) {
                    for (xowl.lang.owl2.Annotation annotation : axiom.getAllAnnotations())
                        translate_Annotation(main, annotation);
                }
            }
        }
        protected void translate_axiom_InverseObjectProperties(xowl.lang.owl2.InverseObjectProperties axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFSubjectNode inv = translate_exp_objectPropertyExpression(axiom.getInverse());
            RDFTriple triple = getTriple(prop, VocRDF.owlInverseOf, inv);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_ObjectPropertyDomain(xowl.lang.owl2.ObjectPropertyDomain axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFSubjectNode classe = translate_exp_classExpression(axiom.getClasse());
            RDFTriple triple = getTriple(prop, VocRDF.rdfsDomain, classe);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_ObjectPropertyRange(xowl.lang.owl2.ObjectPropertyRange axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFSubjectNode classe = translate_exp_classExpression(axiom.getClasse());
            RDFTriple triple = getTriple(prop, VocRDF.rdfsRange, classe);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_FunctionalObjectProperty(xowl.lang.owl2.FunctionalObjectProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlFunctionalProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_InverseFunctionalObjectProperty(xowl.lang.owl2.InverseFunctionalObjectProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlInverseFunctionalProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_ReflexiveObjectProperty(xowl.lang.owl2.ReflexiveObjectProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlReflexiveProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_IrreflexiveObjectProperty(xowl.lang.owl2.IrreflexiveObjectProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlIrreflexiveProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_SymmetricObjectProperty(xowl.lang.owl2.SymmetricObjectProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlSymmetricProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_AsymmetricObjectProperty(xowl.lang.owl2.AsymmetricObjectProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlAsymmetricProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_TransitiveObjectProperty(xowl.lang.owl2.TransitiveObjectProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlTransitiveProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_SubDataPropertyOf(xowl.lang.owl2.SubDataPropertyOf axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode sub = translate_exp_dataPropertyExpression(axiom.getDataProperty());
            RDFSubjectNode sup = translate_exp_dataPropertyExpression(axiom.getSuperDataProperty());
            RDFTriple triple = getTriple(sub, VocRDF.rdfsSubPropertyOf, sup);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_EquivalentDataProperties(xowl.lang.owl2.EquivalentDataProperties axiom) throws xowl.interpreter.XOWLException {
            List<RDFSubjectNode> elements = new ArrayList<RDFSubjectNode>();
            for (xowl.lang.owl2.DataPropertyExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getDataPropertySeq()))
                elements.add(translate_exp_dataPropertyExpression(elem));
            for (int i=0; i!=elements.size()-1; i++) {
                RDFTriple triple = getTriple(elements.get(i), VocRDF.owlEquivalentProperty, elements.get(i+1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            }
        }
        protected void translate_axiom_DisjointDataProperties(xowl.lang.owl2.DisjointDataProperties axiom) throws xowl.interpreter.XOWLException {
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.DataPropertyExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getDataPropertySeq()))
                elements.add(translate_exp_dataPropertyExpression(elem));
            if (elements.size() == 2) {
                RDFTriple triple = getTriple((RDFSubjectNode)elements.get(0), VocRDF.owlPropertyDisjointWith, elements.get(1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            } else {
                RDFSubjectNode main = graph.getBlankNode();
                triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlAllDisjointProperties));
                triples.add(getTriple(main, VocRDF.owlMembers, translate_Sequence_Unordered(elements)));
                if (translateAnnotations) {
                    for (xowl.lang.owl2.Annotation annotation : axiom.getAllAnnotations())
                        translate_Annotation(main, annotation);
                }
            }
        }
        protected void translate_axiom_DataPropertyDomain(xowl.lang.owl2.DataPropertyDomain axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(axiom.getDataProperty());
            RDFSubjectNode classe = translate_exp_classExpression(axiom.getClasse());
            RDFTriple triple = getTriple(prop, VocRDF.rdfsDomain, classe);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_DataPropertyRange(xowl.lang.owl2.DataPropertyRange axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(axiom.getDataProperty());
            RDFSubjectNode datatype = translate_exp_datarange(axiom.getDatarange());
            RDFTriple triple = getTriple(prop, VocRDF.rdfsRange, datatype);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_FunctionalDataProperty(xowl.lang.owl2.FunctionalDataProperty axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(axiom.getDataProperty());
            RDFTriple triple = getTriple(prop, VocRDF.rdfType, VocRDF.owlFunctionalProperty);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_SameIndividual(xowl.lang.owl2.SameIndividual axiom) throws xowl.interpreter.XOWLException {
            List<RDFSubjectNode> elements = new ArrayList<RDFSubjectNode>();
            for (xowl.lang.owl2.IndividualExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getIndividualSeq()))
                elements.add(translate_exp_individualExpression(elem));
            for (int i=0; i!=elements.size()-1; i++) {
                RDFTriple triple = getTriple(elements.get(i), VocRDF.owlSameAs, elements.get(i+1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            }
        }
        protected void translate_axiom_DifferentIndividuals(xowl.lang.owl2.DifferentIndividuals axiom) throws xowl.interpreter.XOWLException {
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.IndividualExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getIndividualSeq()))
                elements.add(translate_exp_individualExpression(elem));
            if (elements.size() == 2) {
                RDFTriple triple = getTriple((RDFSubjectNode)elements.get(0), VocRDF.owlDifferentFrom, elements.get(1));
                triples.add(triple);
                if (translateAnnotations)
                    translate_AxiomAnnotations(axiom, triple);
            } else {
                RDFSubjectNode main = graph.getBlankNode();
                triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlAllDifferent));
                triples.add(getTriple(main, VocRDF.owlMembers, translate_Sequence_Unordered(elements)));
                if (translateAnnotations) {
                    for (xowl.lang.owl2.Annotation annotation : axiom.getAllAnnotations())
                        translate_Annotation(main, annotation);
                }
            }
        }
        protected void translate_axiom_ClassAssertion(xowl.lang.owl2.ClassAssertion axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode ind = translate_exp_individualExpression(axiom.getIndividual());
            RDFSubjectNode classe = translate_exp_classExpression(axiom.getClasse());
            RDFTriple triple = getTriple(ind, VocRDF.rdfType, classe);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_ObjectPropertyAssertion(xowl.lang.owl2.ObjectPropertyAssertion axiom) throws xowl.interpreter.XOWLException {
            RDFProperty prop = null;
            if (axiom.getObjectProperty() instanceof xowl.lang.owl2.ObjectInverseOf) {
                xowl.lang.owl2.ObjectInverseOf expInv = (xowl.lang.owl2.ObjectInverseOf)axiom.getObjectProperty();
                prop = (RDFProperty)translate_exp_objectPropertyExpression(expInv.getInverse());
            } else
                prop = (RDFProperty)translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFSubjectNode ind = translate_exp_individualExpression(axiom.getIndividual());
            RDFSubjectNode value = translate_exp_individualExpression(axiom.getValueIndividual());
            RDFTriple triple = new RDFTriple(ind, prop, value);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_NegativeObjectPropertyAssertion(xowl.lang.owl2.NegativeObjectPropertyAssertion axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode main = graph.getBlankNode();
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(axiom.getObjectProperty());
            RDFSubjectNode ind = translate_exp_individualExpression(axiom.getIndividual());
            RDFSubjectNode value = translate_exp_individualExpression(axiom.getValueIndividual());
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlNegativePropertyAssertion));
            triples.add(getTriple(main, VocRDF.owlSourceIndividual, ind));
            triples.add(getTriple(main, VocRDF.owlAssertionProperty, prop));
            triples.add(getTriple(main, VocRDF.owlTargetIndividual, value));
            if (translateAnnotations) {
                for (xowl.lang.owl2.Annotation annotation : axiom.getAllAnnotations())
                    translate_Annotation(main, annotation);
            }
        }
        protected void translate_axiom_DataPropertyAssertion(xowl.lang.owl2.DataPropertyAssertion axiom) throws xowl.interpreter.XOWLException {
            RDFProperty prop = (RDFProperty)translate_exp_dataPropertyExpression(axiom.getDataProperty());
            RDFSubjectNode ind = translate_exp_individualExpression(axiom.getIndividual());
            RDFNode value = translate_exp_literalExpression(axiom.getValueLiteral());
            RDFTriple triple = new RDFTriple(ind, prop, value);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_NegativeDataPropertyAssertion(xowl.lang.owl2.NegativeDataPropertyAssertion axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode main = graph.getBlankNode();
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(axiom.getDataProperty());
            RDFSubjectNode ind = translate_exp_individualExpression(axiom.getIndividual());
            RDFNode value = translate_exp_literalExpression(axiom.getValueLiteral());
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlNegativePropertyAssertion));
            triples.add(getTriple(main, VocRDF.owlSourceIndividual, ind));
            triples.add(getTriple(main, VocRDF.owlAssertionProperty, prop));
            triples.add(getTriple(main, VocRDF.owlTargetValue, value));
            if (translateAnnotations) {
                for (xowl.lang.owl2.Annotation annotation : axiom.getAllAnnotations())
                    translate_Annotation(main, annotation);
            }
        }
        protected void translate_axiom_HasKey(xowl.lang.owl2.HasKey axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode classe = translate_exp_classExpression(axiom.getClasse());
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.ObjectPropertyExpression exp : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getObjectPropertySeq()))
                elements.add(translate_exp_objectPropertyExpression(exp));
            for (xowl.lang.owl2.DataPropertyExpression exp : xowl.interpreter.impl.Sequences.toExpressionList(axiom.getDataPropertySeq()))
                elements.add(translate_exp_dataPropertyExpression(exp));
            RDFTriple triple = getTriple(classe, VocRDF.owlHasKey, translate_Sequence_Unordered(elements));
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        protected void translate_axiom_SubAnnotationPropertyOf(xowl.lang.owl2.SubAnnotationPropertyOf axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode sub = translate_exp_annotationProperty(axiom.getAnnotProperty());
            RDFSubjectNode sup = translate_exp_annotationProperty(axiom.getSuperAnnotProperty());
            triples.add(getTriple(sub, VocRDF.rdfsSubPropertyOf, sup));
        }
        protected void translate_axiom_AnnotationPropertyDomain(xowl.lang.owl2.AnnotationPropertyDomain axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_annotationProperty(axiom.getAnnotProperty());
            triples.add(getTriple(prop, VocRDF.rdfsDomain, graph.getEntityNode(axiom.getAnnotDomain())));
        }
        protected void translate_axiom_AnnotationPropertyRange(xowl.lang.owl2.AnnotationPropertyRange axiom) throws xowl.interpreter.XOWLException {
            RDFSubjectNode prop = translate_exp_annotationProperty(axiom.getAnnotProperty());
            triples.add(getTriple(prop, VocRDF.rdfsRange, graph.getEntityNode(axiom.getAnnotRange())));
        }
        protected void translate_axiom_AnnotationAssertion(xowl.lang.owl2.AnnotationAssertion axiom) throws xowl.interpreter.XOWLException {
            RDFIRIReference prop = translate_exp_annotationProperty(axiom.getAnnotProperty());
            RDFSubjectNode subject = translate_exp_annotationSubject(axiom.getAnnotSubject());
            RDFNode value = translate_exp_annotationValue(axiom.getAnnotValue());
            RDFTriple triple = new RDFTriple(subject, prop, value);
            triples.add(triple);
            if (translateAnnotations)
                translate_AxiomAnnotations(axiom, triple);
        }
        // </editor-fold>
        
        // <editor-fold defaultstate="collapsed" desc="translate_sequence">
        protected RDFSubjectNode translate_Sequence_Ordered(List<RDFNode> elements) {
            if (elements.isEmpty())
                return graph.getEntityNode(iriProvider.getIRI(VocRDF.rdfNil));
            LinkedList<RDFSubjectNode> proxies = new LinkedList<RDFSubjectNode>();
            for (RDFNode elem : elements) {
                RDFBlankNode proxy = graph.getBlankNode();
                proxies.add(proxy);
                triples.add(getTriple(proxy, VocRDF.rdfFirst, elem));
            }
            for (int i=0; i!=elements.size()-1; i++)
                triples.add(getTriple(proxies.get(i), VocRDF.rdfRest, proxies.get(i+1)));
            triples.add(getTriple(proxies.getLast(), VocRDF.rdfRest, VocRDF.rdfNil));
            return proxies.getFirst();
        }
        
        protected RDFSubjectNode translate_Sequence_Unordered(List<RDFNode> elements) {
            return translate_Sequence_Ordered(elements);
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate_exp_classExpression">
        protected RDFSubjectNode translate_exp_classExpression(xowl.lang.owl2.ClassExpression expression) throws xowl.interpreter.XOWLException {
            if (xowl.utils.Values.isDynamicExpression(expression)) {
                if (evalDynamics)
                    return translate_exp_class(evaluator.evalClass(evaluator, expression));
                return getDynamicNode(expression, xowl.lang.runtime.Class.class);
            }
            if (xowl.utils.Values.isQueryVar(expression)) {
                if (evaluator.can(expression))
                    return translate_exp_class(evaluator.evalClass(evaluator, expression));
                else
                    return context.getVariableNode((xowl.lang.actions.QueryVariable)expression, xowl.lang.runtime.Class.class);
            }
            if (expression instanceof xowl.lang.owl2.IRI) return translate_exp_class((xowl.lang.owl2.IRI)expression);
            if (expression instanceof xowl.lang.owl2.ObjectUnionOf) return translate_exp_objectUnionOf((xowl.lang.owl2.ObjectUnionOf)expression);
            if (expression instanceof xowl.lang.owl2.ObjectIntersectionOf) return translate_exp_objectIntersectionOf((xowl.lang.owl2.ObjectIntersectionOf)expression);
            if (expression instanceof xowl.lang.owl2.ObjectOneOf) return translate_exp_objectOneOf((xowl.lang.owl2.ObjectOneOf)expression);
            if (expression instanceof xowl.lang.owl2.ObjectComplementOf) return translate_exp_objectComplementOf((xowl.lang.owl2.ObjectComplementOf)expression);
            if (expression instanceof xowl.lang.owl2.DataAllValuesFrom) return translate_exp_dataAllValuesFrom((xowl.lang.owl2.DataAllValuesFrom)expression);
            if (expression instanceof xowl.lang.owl2.DataExactCardinality) return translate_exp_dataExactCardinality((xowl.lang.owl2.DataExactCardinality)expression);
            if (expression instanceof xowl.lang.owl2.DataHasValue) return translate_exp_dataHasValue((xowl.lang.owl2.DataHasValue)expression);
            if (expression instanceof xowl.lang.owl2.DataMaxCardinality) return translate_exp_dataMaxCardinality((xowl.lang.owl2.DataMaxCardinality)expression);
            if (expression instanceof xowl.lang.owl2.DataMinCardinality) return translate_exp_dataMinCardinality((xowl.lang.owl2.DataMinCardinality)expression);
            if (expression instanceof xowl.lang.owl2.DataSomeValuesFrom) return translate_exp_dataSomeValuesFrom((xowl.lang.owl2.DataSomeValuesFrom)expression);
            if (expression instanceof xowl.lang.owl2.ObjectAllValuesFrom) return translate_exp_objectAllValuesFrom((xowl.lang.owl2.ObjectAllValuesFrom)expression);
            if (expression instanceof xowl.lang.owl2.ObjectExactCardinality) return translate_exp_objectExactCardinality((xowl.lang.owl2.ObjectExactCardinality)expression);
            if (expression instanceof xowl.lang.owl2.ObjectHasSelf) return translate_exp_objectHasSelf((xowl.lang.owl2.ObjectHasSelf)expression);
            if (expression instanceof xowl.lang.owl2.ObjectHasValue) return translate_exp_objectHasValue((xowl.lang.owl2.ObjectHasValue)expression);
            if (expression instanceof xowl.lang.owl2.ObjectMaxCardinality) return translate_exp_objectMaxCardinality((xowl.lang.owl2.ObjectMaxCardinality)expression);
            if (expression instanceof xowl.lang.owl2.ObjectMinCardinality) return translate_exp_objectMinCardinality((xowl.lang.owl2.ObjectMinCardinality)expression);
            if (expression instanceof xowl.lang.owl2.ObjectSomeValuesFrom) return translate_exp_objectSomeValuesFrom((xowl.lang.owl2.ObjectSomeValuesFrom)expression);
            return null;
        }
        protected RDFSubjectNode translate_exp_class(xowl.lang.owl2.IRI expression) throws xowl.interpreter.XOWLException {
            evaluator.evalClass(evaluator, expression);
            return graph.getEntityNode((xowl.lang.owl2.IRI)expression);
        }
        protected RDFSubjectNode translate_exp_class(xowl.lang.runtime.Class expression) throws xowl.interpreter.XOWLException {
            // Here an OWL Class is expected to be a named Class
            if (expression.getInterpretationOf() == null)
                throw new xowl.interpreter.XOWLException("XOWL->RDF Translator cannot translate anonymous entities");
            return graph.getEntityNode(expression.getInterpretationOf().getHasIRI());
        }
        protected RDFSubjectNode translate_exp_objectUnionOf(xowl.lang.owl2.ObjectUnionOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlClass));
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.ClassExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getClassSeq()))
                elements.add(translate_exp_classExpression(elem));
            RDFSubjectNode seq = translate_Sequence_Unordered(elements);
            triples.add(getTriple(main, VocRDF.owlUnionOf, seq));
            return main;
        }
        protected RDFSubjectNode translate_exp_objectIntersectionOf(xowl.lang.owl2.ObjectIntersectionOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlClass));
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.ClassExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getClassSeq()))
                elements.add(translate_exp_classExpression(elem));
            RDFSubjectNode seq = translate_Sequence_Unordered(elements);
            triples.add(getTriple(main, VocRDF.owlIntersectionOf, seq));
            return main;
        }
        protected RDFSubjectNode translate_exp_objectOneOf(xowl.lang.owl2.ObjectOneOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlClass));
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.IndividualExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getIndividualSeq()))
                elements.add(translate_exp_individualExpression(elem));
            RDFSubjectNode seq = translate_Sequence_Unordered(elements);
            triples.add(getTriple(main, VocRDF.owlOneOf, seq));
            return main;
        }
        protected RDFSubjectNode translate_exp_objectComplementOf(xowl.lang.owl2.ObjectComplementOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlClass));
            RDFSubjectNode comp = translate_exp_classExpression(expression.getClasse());
            triples.add(getTriple(main, VocRDF.owlComplementOf, comp));
            return main;
        }
        protected RDFSubjectNode translate_exp_dataAllValuesFrom(xowl.lang.owl2.DataAllValuesFrom expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            LinkedList<RDFNode> elements = new LinkedList<RDFNode>();
            for (xowl.lang.owl2.DataPropertyExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getDataPropertySeq()))
                elements.add(translate_exp_dataPropertyExpression(elem));
            if (elements.size() == 1)
                triples.add(getTriple(main, VocRDF.owlOnProperty, elements.getFirst()));
            else
                triples.add(getTriple(main, VocRDF.owlOnProperties, translate_Sequence_Unordered(elements)));
            RDFSubjectNode datarange = translate_exp_datarange(expression.getDatarange());
            triples.add(getTriple(main, VocRDF.owlAllValuesFrom, datarange));
            return main;
        }
        protected RDFSubjectNode translate_exp_dataExactCardinality(xowl.lang.owl2.DataExactCardinality expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFNode n = translate_exp_literalExpression(expression.getCardinality());
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(expression.getDataProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            if (expression.getDatarange() != null) {
                triples.add(getTriple(main, VocRDF.owlQualifiedCardinality, n));
                RDFSubjectNode datarange = translate_exp_datarange(expression.getDatarange());
                triples.add(getTriple(main, VocRDF.owlOnDatarange, datarange));
            } else {
                triples.add(getTriple(main, VocRDF.owlCardinality, n));
            }
            return main;
        }
        protected RDFSubjectNode translate_exp_dataHasValue(xowl.lang.owl2.DataHasValue expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(expression.getDataProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            RDFNode value = translate_exp_literalExpression(expression.getLiteral());
            triples.add(getTriple(main, VocRDF.owlHasValue, value));
            return main;
        }
        protected RDFSubjectNode translate_exp_dataMaxCardinality(xowl.lang.owl2.DataMaxCardinality expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFNode n = translate_exp_literalExpression(expression.getCardinality());
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(expression.getDataProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            if (expression.getDatarange() != null) {
                triples.add(getTriple(main, VocRDF.owlMaxQualifiedCardinality, n));
                RDFSubjectNode datarange = translate_exp_datarange(expression.getDatarange());
                triples.add(getTriple(main, VocRDF.owlOnDatarange, datarange));
            } else {
                triples.add(getTriple(main, VocRDF.owlMaxCardinality, n));
            }
            return main;
        }
        protected RDFSubjectNode translate_exp_dataMinCardinality(xowl.lang.owl2.DataMinCardinality expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFNode n = translate_exp_literalExpression(expression.getCardinality());
            RDFSubjectNode prop = translate_exp_dataPropertyExpression(expression.getDataProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            if (expression.getDatarange() != null) {
                triples.add(getTriple(main, VocRDF.owlMinQualifiedCardinality, n));
                RDFSubjectNode datarange = translate_exp_datarange(expression.getDatarange());
                triples.add(getTriple(main, VocRDF.owlOnDatarange, datarange));
            } else {
                triples.add(getTriple(main, VocRDF.owlMinCardinality, n));
            }
            return main;
        }
        protected RDFSubjectNode translate_exp_dataSomeValuesFrom(xowl.lang.owl2.DataSomeValuesFrom expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            LinkedList<RDFNode> elements = new LinkedList<RDFNode>();
            for (xowl.lang.owl2.DataPropertyExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getDataPropertySeq()))
                elements.add(translate_exp_dataPropertyExpression(elem));
            if (elements.size() == 1)
                triples.add(getTriple(main, VocRDF.owlOnProperty, elements.getFirst()));
            else
                triples.add(getTriple(main, VocRDF.owlOnProperties, translate_Sequence_Unordered(elements)));
            RDFSubjectNode datarange = translate_exp_datarange(expression.getDatarange());
            triples.add(getTriple(main, VocRDF.owlSomeValuesFrom, datarange));
            return main;
        }
        protected RDFSubjectNode translate_exp_objectAllValuesFrom(xowl.lang.owl2.ObjectAllValuesFrom expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(expression.getObjectProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            RDFSubjectNode classe = translate_exp_classExpression(expression.getClasse());
            triples.add(getTriple(main, VocRDF.owlAllValuesFrom, classe));
            return main;
        }
        protected RDFSubjectNode translate_exp_objectExactCardinality(xowl.lang.owl2.ObjectExactCardinality expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFNode n = translate_exp_literalExpression(expression.getCardinality());
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(expression.getObjectProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            if (expression.getClasse() != null) {
                triples.add(getTriple(main, VocRDF.owlQualifiedCardinality, n));
                RDFSubjectNode classe = translate_exp_classExpression(expression.getClasse());
                triples.add(getTriple(main, VocRDF.owlOnDatarange, classe));
            } else {
                triples.add(getTriple(main, VocRDF.owlCardinality, n));
            }
            return main;
        }
        protected RDFSubjectNode translate_exp_objectHasSelf(xowl.lang.owl2.ObjectHasSelf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(expression.getObjectProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            RDFNode valueTrue = translate_exp_literalExpression(xowl.utils.Values.getExpression(iriProvider, true));
            triples.add(getTriple(main, VocRDF.owlHasSelf, valueTrue));
            return main;
        }
        protected RDFSubjectNode translate_exp_objectHasValue(xowl.lang.owl2.ObjectHasValue expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(expression.getObjectProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            RDFSubjectNode ind = translate_exp_individualExpression(expression.getIndividual());
            triples.add(getTriple(main, VocRDF.owlHasValue, ind));
            return main;
        }
        protected RDFSubjectNode translate_exp_objectMaxCardinality(xowl.lang.owl2.ObjectMaxCardinality expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFNode n = translate_exp_literalExpression(expression.getCardinality());
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(expression.getObjectProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            if (expression.getClasse() != null) {
                triples.add(getTriple(main, VocRDF.owlMaxQualifiedCardinality, n));
                RDFSubjectNode classe = translate_exp_classExpression(expression.getClasse());
                triples.add(getTriple(main, VocRDF.owlOnDatarange, classe));
            } else {
                triples.add(getTriple(main, VocRDF.owlMaxCardinality, n));
            }
            return main;
        }
        protected RDFSubjectNode translate_exp_objectMinCardinality(xowl.lang.owl2.ObjectMinCardinality expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFNode n = translate_exp_literalExpression(expression.getCardinality());
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(expression.getObjectProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            if (expression.getClasse() != null) {
                triples.add(getTriple(main, VocRDF.owlMinQualifiedCardinality, n));
                RDFSubjectNode classe = translate_exp_classExpression(expression.getClasse());
                triples.add(getTriple(main, VocRDF.owlOnDatarange, classe));
            } else {
                triples.add(getTriple(main, VocRDF.owlMinCardinality, n));
            }
            return main;
        }
        protected RDFSubjectNode translate_exp_objectSomeValuesFrom(xowl.lang.owl2.ObjectSomeValuesFrom expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlRestriction));
            RDFSubjectNode prop = translate_exp_objectPropertyExpression(expression.getObjectProperty());
            triples.add(getTriple(main, VocRDF.owlOnProperty, prop));
            RDFSubjectNode classe = translate_exp_classExpression(expression.getClasse());
            triples.add(getTriple(main, VocRDF.owlSomeValuesFrom, classe));
            return main;
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate_exp_objectPropertyExpression">
        protected RDFSubjectNode translate_exp_objectPropertyExpression(xowl.lang.owl2.ObjectPropertyExpression expression) throws xowl.interpreter.XOWLException {
            if (xowl.utils.Values.isDynamicExpression(expression)) {
                if (evalDynamics)
                    return translate_exp_objectProperty(evaluator.evalObjProp(evaluator, expression));
                return getDynamicNode(expression, xowl.lang.runtime.ObjectProperty.class);
            }
            if (xowl.utils.Values.isQueryVar(expression)) {
                if (evaluator.can(expression))
                    return translate_exp_objectProperty(evaluator.evalObjProp(evaluator, expression));
                else
                    return context.getVariableNode((xowl.lang.actions.QueryVariable)expression, xowl.lang.runtime.ObjectProperty.class);
            }
            if (expression instanceof xowl.lang.owl2.IRI) return translate_exp_objectProperty((xowl.lang.owl2.IRI)expression);
            if (expression instanceof xowl.lang.owl2.ObjectInverseOf) return translate_exp_objectInverseOf((xowl.lang.owl2.ObjectInverseOf)expression);
            return null;
        }
        protected RDFSubjectNode translate_exp_objectProperty(xowl.lang.owl2.IRI expression) throws xowl.interpreter.XOWLException {
            evaluator.evalObjProp(evaluator, expression);
            return graph.getEntityNode((xowl.lang.owl2.IRI)expression);
        }
        protected RDFSubjectNode translate_exp_objectProperty(xowl.lang.runtime.ObjectProperty expression) throws xowl.interpreter.XOWLException {
            if (expression.getInterpretationOf() == null)
                throw new xowl.interpreter.XOWLException("XOWL->RDF Translator cannot translate anonymous entities");
            return graph.getEntityNode(expression.getInterpretationOf().getHasIRI());
        }
        protected RDFSubjectNode translate_exp_objectInverseOf(xowl.lang.owl2.ObjectInverseOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            RDFSubjectNode inv = translate_exp_objectPropertyExpression(expression.getInverse());
            triples.add(getTriple(main, VocRDF.owlInverseOf, inv));
            return main;
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate_exp_dataPropertyExpression">
        protected RDFSubjectNode translate_exp_dataPropertyExpression(xowl.lang.owl2.DataPropertyExpression expression) throws xowl.interpreter.XOWLException {
            if (xowl.utils.Values.isDynamicExpression(expression)) {
                if (evalDynamics)
                    return translate_exp_dataProperty(evaluator.evalDataProp(evaluator, expression));
                return getDynamicNode(expression, xowl.lang.runtime.DataProperty.class);
            }
            if (xowl.utils.Values.isQueryVar(expression)) {
                if (evaluator.can(expression))
                    return translate_exp_dataProperty(evaluator.evalDataProp(evaluator, expression));
                else
                    return context.getVariableNode((xowl.lang.actions.QueryVariable)expression, xowl.lang.runtime.DataProperty.class);
            }
            if (expression instanceof xowl.lang.owl2.IRI) return translate_exp_dataProperty((xowl.lang.owl2.IRI)expression);
            return null;
        }
        protected RDFSubjectNode translate_exp_dataProperty(xowl.lang.owl2.IRI expression) throws xowl.interpreter.XOWLException {
            evaluator.evalDataProp(evaluator, expression);
            return graph.getEntityNode((xowl.lang.owl2.IRI)expression);
        }
        protected RDFSubjectNode translate_exp_dataProperty(xowl.lang.runtime.DataProperty expression) throws xowl.interpreter.XOWLException {
            if (expression.getInterpretationOf() == null)
                throw new xowl.interpreter.XOWLException("XOWL->RDF Translator cannot translate anonymous entities");
            return graph.getEntityNode(expression.getInterpretationOf().getHasIRI());
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate_exp_datarange">
        protected RDFSubjectNode translate_exp_datarange(xowl.lang.owl2.Datarange expression) throws xowl.interpreter.XOWLException {
            if (xowl.utils.Values.isDynamicExpression(expression)) {
                if (evalDynamics)
                    return translate_exp_datatype(evaluator.evalDatatype(evaluator, expression));
                return getDynamicNode(expression, xowl.lang.runtime.Datatype.class);
            }
            if (xowl.utils.Values.isQueryVar(expression)) {
                if (evaluator.can(expression))
                    return translate_exp_datatype(evaluator.evalDatatype(evaluator, expression));
                else
                    return context.getVariableNode((xowl.lang.actions.QueryVariable)expression, xowl.lang.runtime.Datatype.class);
            }
            if (expression instanceof xowl.lang.owl2.IRI) return translate_exp_datatype((xowl.lang.owl2.IRI)expression);
            if (expression instanceof xowl.lang.owl2.DataComplementOf) return translate_exp_dataComplementOf((xowl.lang.owl2.DataComplementOf)expression);
            if (expression instanceof xowl.lang.owl2.DataIntersectionOf) return translate_exp_dataIntersectionOf((xowl.lang.owl2.DataIntersectionOf)expression);
            if (expression instanceof xowl.lang.owl2.DataOneOf) return translate_exp_dataOneOf((xowl.lang.owl2.DataOneOf)expression);
            if (expression instanceof xowl.lang.owl2.DatatypeRestriction) return translate_exp_datatypeRestriction((xowl.lang.owl2.DatatypeRestriction)expression);
            if (expression instanceof xowl.lang.owl2.DataUnionOf) return translate_exp_dataUnionOf((xowl.lang.owl2.DataUnionOf)expression);
            return null;
        }
        protected RDFSubjectNode translate_exp_datatype(xowl.lang.owl2.IRI expression) throws xowl.interpreter.XOWLException {
            evaluator.evalDatatype(evaluator, expression);
            return graph.getEntityNode((xowl.lang.owl2.IRI)expression);
        }
        protected RDFSubjectNode translate_exp_datatype(xowl.lang.runtime.Datatype expression) throws xowl.interpreter.XOWLException {
            if (expression.getInterpretationOf() == null)
                throw new xowl.interpreter.XOWLException("XOWL->RDF Translator cannot translate anonymous entities");
            return graph.getEntityNode(expression.getInterpretationOf().getHasIRI());
        }
        protected RDFSubjectNode translate_exp_dataComplementOf(xowl.lang.owl2.DataComplementOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.rdfsDatatype));
            RDFSubjectNode comp = translate_exp_datarange(expression.getDatarange());
            triples.add(getTriple(main, VocRDF.owlDatatypeComplementOf, comp));
            return main;
        }
        protected RDFSubjectNode translate_exp_dataIntersectionOf(xowl.lang.owl2.DataIntersectionOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.rdfsDatatype));
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.Datarange elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getDatarangeSeq()))
                elements.add(translate_exp_datarange(elem));
            RDFSubjectNode seq = translate_Sequence_Unordered(elements);
            triples.add(getTriple(main, VocRDF.owlIntersectionOf, seq));
            return main;
        }
        protected RDFSubjectNode translate_exp_dataOneOf(xowl.lang.owl2.DataOneOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.rdfsDatatype));
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.LiteralExpression elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getLiteralSeq()))
                elements.add(translate_exp_literalExpression(elem));
            RDFSubjectNode seq = translate_Sequence_Unordered(elements);
            triples.add(getTriple(main, VocRDF.owlOneOf, seq));
            return main;
        }
        protected RDFSubjectNode translate_exp_datatypeRestriction(xowl.lang.owl2.DatatypeRestriction expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.rdfsDatatype));
            RDFSubjectNode base = translate_exp_datarange(expression.getDatarange());
            triples.add(getTriple(main, VocRDF.owlOnDatatype, base));
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.FacetRestriction elem : expression.getAllFacetRestrictions())
                elements.add(translate_exp_datatypeRestriction_Restriction(elem));
            RDFSubjectNode seq = translate_Sequence_Unordered(elements);
            triples.add(getTriple(main, VocRDF.owlWithRestrictions, seq));
            return main;
        }
        protected RDFSubjectNode translate_exp_datatypeRestriction_Restriction(xowl.lang.owl2.FacetRestriction restriction) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            RDFNode lit = translate_exp_literalExpression(restriction.getConstrainingValue());
            triples.add(getTriple(main, restriction.getConstrainingFacet().getHasValue(), lit));
            return main;
        }
        protected RDFSubjectNode translate_exp_dataUnionOf(xowl.lang.owl2.DataUnionOf expression) throws xowl.interpreter.XOWLException {
            RDFBlankNode main = graph.getBlankNode();
            triples.add(getTriple(main, VocRDF.rdfType, VocRDF.rdfsDatatype));
            List<RDFNode> elements = new ArrayList<RDFNode>();
            for (xowl.lang.owl2.Datarange elem : xowl.interpreter.impl.Sequences.toExpressionList(expression.getDatarangeSeq()))
                elements.add(translate_exp_datarange(elem));
            RDFSubjectNode seq = translate_Sequence_Unordered(elements);
            triples.add(getTriple(main, VocRDF.owlUnionOf, seq));
            return main;
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate_exp_individualExpression">
        protected RDFSubjectNode translate_exp_individualExpression(xowl.lang.owl2.IndividualExpression expression) throws xowl.interpreter.XOWLException {
            if (xowl.utils.Values.isDynamicExpression(expression)) {
                if (evalDynamics) {
                    xowl.lang.runtime.Individual ind = evaluator.evalIndividual(evaluator, expression);
                    if (ind instanceof xowl.lang.owl2.AnonymousIndividual) return translate_exp_anonymousIndividual((xowl.lang.owl2.AnonymousIndividual)ind);
                    if (ind instanceof xowl.lang.runtime.NamedIndividual) return translate_exp_namedIndividual((xowl.lang.runtime.NamedIndividual)ind);
                } else
                    return getDynamicNode(expression, xowl.lang.runtime.Individual.class);
            }
            if (xowl.utils.Values.isQueryVar(expression)) {
                if (evaluator.can(expression)) {
                    xowl.lang.runtime.Individual ind = evaluator.evalIndividual(evaluator, expression);
                    if (ind instanceof xowl.lang.owl2.AnonymousIndividual) return translate_exp_anonymousIndividual((xowl.lang.owl2.AnonymousIndividual)ind);
                    if (ind instanceof xowl.lang.runtime.NamedIndividual) return translate_exp_namedIndividual((xowl.lang.runtime.NamedIndividual)ind);
                } else
                    return context.getVariableNode((xowl.lang.actions.QueryVariable)expression, xowl.lang.runtime.Individual.class);
            }
            if (expression instanceof xowl.lang.owl2.IRI) return translate_exp_namedIndividual((xowl.lang.owl2.IRI)expression);
            if (expression instanceof xowl.lang.owl2.AnonymousIndividual) return translate_exp_anonymousIndividual((xowl.lang.owl2.AnonymousIndividual)expression);
            return null;
        }
        protected RDFSubjectNode translate_exp_namedIndividual(xowl.lang.owl2.IRI expression) throws xowl.interpreter.XOWLException {
            evaluator.evalIndividual(evaluator, expression);
            return graph.getEntityNode((xowl.lang.owl2.IRI)expression);
        }
        protected RDFSubjectNode translate_exp_namedIndividual(xowl.lang.runtime.NamedIndividual expression) throws xowl.interpreter.XOWLException {
            if (expression.getInterpretationOf() == null)
                throw new xowl.interpreter.XOWLException("XOWL->RDF Translator cannot translate anonymous entities");
            return graph.getEntityNode(expression.getInterpretationOf().getHasIRI());
        }
        protected RDFSubjectNode translate_exp_anonymousIndividual(xowl.lang.owl2.AnonymousIndividual expression) throws xowl.interpreter.XOWLException {
            return graph.getBlankNode(expression);
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate_exp_literalExpression">
        protected RDFNode translate_exp_literalExpression(xowl.lang.owl2.LiteralExpression expression) throws xowl.interpreter.XOWLException {
            if (xowl.utils.Values.isDynamicExpression(expression)) {
                if (evalDynamics)
                    return translate_exp_literal(evaluator.evalLiteral(evaluator, expression));
                return getDynamicNode(expression, xowl.lang.owl2.Literal.class);
            }
            if (xowl.utils.Values.isQueryVar(expression)) {
                if (evaluator.can(expression))
                    return translate_exp_literal(evaluator.evalLiteral(evaluator, expression));
                else
                    return context.getVariableNode((xowl.lang.actions.QueryVariable)expression, xowl.lang.owl2.Literal.class);
            }
            if (expression instanceof xowl.lang.owl2.Literal) return translate_exp_literal(evaluator.evalLiteral(evaluator, expression));
            return null;
        }
        protected RDFLiteralNode translate_exp_literal(xowl.lang.runtime.Literal expression) throws xowl.interpreter.XOWLException {
            return graph.getLiteralNode(expression);
        }
        // </editor-fold>

        // <editor-fold defaultstate="collapsed" desc="translate annotations">
        protected RDFIRIReference translate_exp_annotationProperty(xowl.lang.owl2.IRI expression) throws xowl.interpreter.XOWLException {
            // Here an OWL Class is expected to be a named Class
            return graph.getEntityNode(expression);
        }
        protected RDFSubjectNode translate_exp_annotationSubject(xowl.lang.owl2.AnnotationSubject expression) throws xowl.interpreter.XOWLException {
            if (expression instanceof xowl.lang.owl2.IRI)
                return graph.getEntityNode((xowl.lang.owl2.IRI)expression);
            else
                return graph.getBlankNode((xowl.lang.owl2.AnonymousIndividual)expression);
        }
        protected RDFNode translate_exp_annotationValue(xowl.lang.owl2.AnnotationValue expression) throws xowl.interpreter.XOWLException {
            if (expression instanceof xowl.lang.owl2.IRI)
                return graph.getEntityNode((xowl.lang.owl2.IRI)expression);
            else if (expression instanceof xowl.lang.owl2.AnonymousIndividual)
                return graph.getBlankNode((xowl.lang.owl2.AnonymousIndividual)expression);
            else
                return graph.getLiteralNode(evaluator.evalLiteral(evaluator, (xowl.lang.owl2.Literal)expression));
        }
        protected void translate_Annotation(RDFSubjectNode annotated, xowl.lang.owl2.Annotation annotation) throws xowl.interpreter.XOWLException {
            RDFIRIReference prop = translate_exp_annotationProperty(annotation.getAnnotProperty());
            RDFNode value = translate_exp_annotationValue(annotation.getAnnotValue());
            triples.add(new RDFTriple(annotated, prop, value));
            if (!annotation.getAllAnnotations().isEmpty()) {
                RDFSubjectNode main = graph.getBlankNode();
                triples.add(getTriple(main, VocRDF.rdfType, VocRDF.owlAnnotation));
                triples.add(getTriple(main, VocRDF.owlAnnotatedSource, annotated));
                triples.add(getTriple(main, VocRDF.owlAnnotatedProperty, prop));
                triples.add(getTriple(main, VocRDF.owlAnnotatedTarget, value));
                for (xowl.lang.owl2.Annotation child : annotation.getAllAnnotations())
                    translate_Annotation(main, child);
            }
        }
        protected void translate_AxiomAnnotations(xowl.lang.owl2.Axiom axiom, RDFTriple main) throws xowl.interpreter.XOWLException {
            if (!axiom.getAllAnnotations().isEmpty()) {
                RDFSubjectNode x = graph.getBlankNode();
                triples.add(getTriple(x, VocRDF.rdfType, VocRDF.owlAxiom));
                triples.add(getTriple(x, VocRDF.owlAnnotatedSource, main.getSubject()));
                triples.add(getTriple(x, VocRDF.owlAnnotatedProperty, main.getProperty()));
                triples.add(getTriple(x, VocRDF.owlAnnotatedTarget, main.getObject()));
                for (xowl.lang.owl2.Annotation child : axiom.getAllAnnotations())
                    translate_Annotation(x, child);
            }
        }
        // </editor-fold>
    }
}
